package com.my.drinkinggame;

import java.util.ArrayList;
import java.util.HashMap;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.my.screens.AddedCards;
import com.my.screens.CreateCard;
import com.my.screens.MyDrinkingGame;
import com.my.screens.MainMenu;
import com.my.screens.NewGame;
import com.my.screens.RulesScreen;
import com.my.screens.Screen;

//main class
public class Main implements ApplicationListener{
	public static final Integer SCREEN_MAINMENU = 0;
	public static final Integer SCREEN_GAME = 1;
	public static final Integer SCREEN_CREATECARD = 2;
	public static final Integer SCREEN_ADDEDCARDS = 3;
	public static final Integer SCREEN_NEWGAME = 4;
	public static final Integer SCREEN_RULES = 5;
	public boolean initiated;
	public HashMap<Integer, Screen> screenList;
	public Screen activeScreen;
	
	public void initiate(){
		StaticTextures.initiate();
		StaticSprites.initiate();
		StaticFonts.initiate();
		screenList = new HashMap<Integer, Screen>();
		screenList.put(SCREEN_MAINMENU, new MainMenu(this));
		screenList.put(SCREEN_GAME, new MyDrinkingGame(this, Renderer.getInstance()));
		screenList.put(SCREEN_CREATECARD, new CreateCard(this));
		screenList.put(SCREEN_ADDEDCARDS, new AddedCards(this));
		screenList.put(SCREEN_NEWGAME, new NewGame(this));
		screenList.put(SCREEN_RULES, new RulesScreen(this));
		activeScreen = screenList.get(SCREEN_MAINMENU);
		activeScreen.enter();
		initiated = true;
	}
	
	@Override
	public void create() {
		initiated = false;
	}

	public Screen getState(int id) {
		return screenList.get(id);
	}
	
	public void setScreen(int id) {
		activeScreen = screenList.get(id);
		activeScreen.enter();
	}
	
	@Override
	public void dispose() {
		//DisposableObjects.dispose();
	}

	@Override
	public void pause() {	
	}

	@Override
	public void render() {
		GL20 gl = Gdx.graphics.getGL20();
		gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		if (initiated) {
			activeScreen.update();
			activeScreen.render();
		}
		else{
			initiate();
		}
	}

	@Override
	public void resize(int arg0, int arg1) {
	
	}

	@Override
	public void resume() {
		
	}

}
